package com.hnevc.yourhealthmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnevc.yourhealthmanager.dto.SportRecordDTO;
import com.hnevc.yourhealthmanager.entity.HealthPlane;
import com.hnevc.yourhealthmanager.entity.HealthUser;
import com.hnevc.yourhealthmanager.entity.SportRecord;
import com.hnevc.yourhealthmanager.dao.SportRecordMapper;
import com.hnevc.yourhealthmanager.service.SportRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SportRecordServiceImpl extends ServiceImpl<SportRecordMapper, SportRecord> implements SportRecordService {
    @Autowired
    SportRecordMapper sportRecordMapper;
    @Override
    public List<SportRecordDTO> getSportRecordListByUserId(Integer userId) {
        return sportRecordMapper.getSportRecordListByUserId(userId);
    }

    @Override
    public List<SportRecordDTO> getSportRecordListByHealthPlane(HealthPlane healthPlane) {
        return sportRecordMapper.getSportRecordListByHealthPlane(healthPlane);
    }

    @Override
    public List<SportRecordDTO> getSportRecordListByPlaneMonth(HealthPlane healthPlane, Integer month, Integer year) {
        return sportRecordMapper.getSportRecordListByPlaneMonth(healthPlane,month,year);
    }

    @Override
    public SportRecord updatePic(Integer id, String filePath) {
        SportRecord sportRecord= sportRecordMapper.selectById(id);
        sportRecord.setSportImage(filePath);
        if(sportRecordMapper.updateById(sportRecord)>0){
            return sportRecord;
        }else{
            return null;
        }
    }
}
